package com.stylefeng.guns.modular.system.warpper;

import java.text.DecimalFormat;
import java.util.Date;
import java.util.Map;

import org.apache.commons.lang.StringUtils;

import com.stylefeng.guns.core.base.warpper.BaseControllerWarpper;
import com.stylefeng.guns.core.util.DateUtil;
import com.stylefeng.guns.modular.system.model.Gdprice;

public class JjGpcWarpper extends BaseControllerWarpper{

	public JjGpcWarpper(Object list) {
        super(list);
    }

    @Override
    public void warpTheMap(Map<String, Object> map) {
    	DecimalFormat df = new DecimalFormat("0.00");
		Date date = ((Date)map.get("gTdate"));
		Gdprice gdprice = new Gdprice();
		gdprice.setgTime(date);
		gdprice.setgDm((String)map.get("gScode"));
		
		map.put("gTdate", DateUtil.format(date, "yyyy-MM-dd"));
    	map.put("ZLCB", df.format((Double)map.get("ZLCB")));
    	map.put("gZsz", df.format(Math.abs(((Double)map.get("gZsz") / 100000000))));
    	double gJqZdf = (Double)map.get("gJqZdf");
		map.put("gJqZdf", (gJqZdf >0 ? "<font color='red'><b>"+df.format(gJqZdf)+"</b></font>" : "<font color='green'><b>"+df.format(gJqZdf)+"</b></font>"));
    	
		String gCzdf = (String)map.get("gCzdf");
		map.put("gCzdf", (StringUtils.contains(gCzdf,"+") ? "<font color='red'><b>"+gCzdf+"</b></font>" : "<font color='green'><b>"+gCzdf+"</b></font>"));
		
    	String JGCYDType = ((String)map.get("JGCYDType"));
    	String font = "";
		if(JGCYDType.equals("不控盘")){
			font = "<font color='DimGray'><b>不控盘</b></font>";
		}else if(JGCYDType.equals("轻度控盘")){
			font = "<font color='BurlyWood'><b>轻度控盘</b></font>";
		}else if(JGCYDType.equals("中度控盘")){
			font = "<font color='Chocolate'><b>中度控盘</b></font>";
		}else{
			font = "<font color='Brown'><b>完全控盘</b></font>";
		}
		map.put("JGCYDType", font);
		
		Object gGpcTdate = map.get("gGpcTdate");
		if(gGpcTdate == null){
			map.put("gGpcTdate", "无");
			map.put("isExits", "<font color='green'><b>否</b></font>");
		}else{
			map.put("gGpcTdate", DateUtil.getDay((Date)gGpcTdate));
			map.put("isExits", "<font color='red'><b>是</b></font>");
		}
    }
}
